package com.jwell.panrank.model

import com.jwell.driverapp.tools.BaseSubscriber
import com.jwell.panrank.application.App
import com.jwell.panrank.contract.MainContract
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by 76577 on 2018/5/8.
 * 首页
 */
class MainModel : MainContract.Model, BaseModel() {
    override fun getMeasurePlaceList(baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("获取收料点点信息")
        getApiStore().getMeasurePlaceList()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    override fun getUnloadingPoint(baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("获取卸车点信息")
        getApiStore().getUnloadingPoint()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    override fun checkPermission(baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("检测用户权限")
        getApiStore().checkUserPermission()
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }
}